// pages/help1/index.js
const app     = getApp()
const request = require('../../utils/request.js');
const config = require('../../utils/config.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        topBarHeight: 64,
        nowList:{  total: 0,
            current_page: 0,
            last_page: 1,
            data: []
        },
    },
    getBarInfo(e) {
        this.setData({
            topBarHeight: e.detail.topBarHeight
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var that =this;
    
        that.init_Data();
    },
    init_Data(){
        var that = this;
        that.setData({
          'nowList.current_page': 0,
      });
      that.helpsList();
    
    
      },
     helpsList()
      {
        var that = this;
        var json = {};
        json.page = Number(that.data.nowList.current_page) + 1;
        if (json.page > 1 && that.data.nowList.current_page >= that.data.nowList.last_page) {       
            return false;
        }
        request.requestLoading(
            "/api/index/helpList",
            json,
            'POST',
          ).then((res) => {
            var nowList = res.data;
            that.setData({
                is_show:true
            })
    
            if (json.page > 1) {
                var now_nowList_data =that.data.nowList.data || [];
                var now_nowList_data = now_nowList_data.concat(nowList.data);
                nowList.data = now_nowList_data;
            }
      
            that.setData({
              nowList: nowList
            });
          
           
           
      
          }).catch((err) => {
            console.error(err);
          });
      },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {
        this.init_Data();
        setTimeout(function(){
          wx.stopPullDownRefresh();
        },500)
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {
        var that =this;

        if (that.data.nowList.current_page >= that.data.nowList.last_page) {
          // functions.toast('已加载到底部了');
          return false;
      } else {
        that.helpsList()
      }
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})